package com.bwie.controller;
import com.bwie.pojo.Repais;
import com.bwie.service.*;
import com.bwie.service.impl.RepaisServiceImpl;
import com.bwie.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.PostConstruct;

/**
* (tb_repais)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/repair/index")
public class RepaisController {
/**
* 服务对象
*/
    @Autowired
    private RepaisService repaisService;

    @Autowired
    private RegionService regionService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private MaintainService maintainService;

    @Autowired
    private RepairUserService repairUserService;

    /**
     * @description: 近两周数据统计
     * @author: Zero
     * @date: 2025/8/30 13:38
     * @param: []
     * @return: com.bwie.utils.R
     **/
    @ApiOperation("近两周数据统计")
    @PostMapping("getWeekCount")
    public R getWeekCount(){
        return repaisService.getWeekCount();
    }

    /**
     * @description:  近一年中每月的维修状态占比
     * @author: Zero
     * @date: 2025/8/30 13:38
     * @param: []
     * @return: com.bwie.utils.R
     **/
    @ApiOperation("近一年中每月的维修状态占比")
    @PostMapping("getYearMonthCount")
    public R getYearMonthCount() {
        return repaisService.getYearMonthCount();
    }

    /**
     * @description: 每个区域中维修状态占比
     * @author: Zero
     * @date: 2025/8/30 13:38
     * @param: []
     * @return: com.bwie.utils.R
     **/
    @ApiOperation("每个区域中维修状态占比")
    @PostMapping("getRegionStatusCount")
    public R getRegionStatusCount(){
        return repaisService.getRegionStatusCount();
    }

    @ApiOperation("获取报修列表")
    @PostMapping("getRepairList")
    public R getRepairList(@RequestBody Repais repais){
        return repaisService.getRepairList(repais);
    }

    @ApiOperation("获取类目")
    @PostMapping("getCateGory")
    public R getCateGory(){
        return categoryService.getCateGory();
    }

    @ApiOperation("获取区域")
    @PostMapping("getRegion")
    public R getRegion(){
        return regionService.getRegion();
    }

  @ApiOperation("获取承修人 ")
    @PostMapping("getRepairUser")
    public R getRepairUser(){
        return repairUserService.getRepairUser();
    }

    @ApiOperation("报修")
    @PostMapping("addRepairs")
    public R addRepairs(@RequestBody Repais repais){
        return repaisService.addRepairs(repais);
    }


    @ApiOperation("上传文件")
    @PostMapping("upLoadFile")
    public R upLoadFile(@RequestPart("file")MultipartFile file){
        return repaisService.upLoadFile(file);
    }

    @ApiOperation("编辑")
    @PostMapping("updateRepair")
    public R updateRepair(@RequestBody Repais repais){
        return repaisService.updateRepair(repais);
    }

    @ApiOperation("获取维修进度表信息")
    @PostMapping("getMaintain/{id}")
    public R getMaintain(@PathVariable("id")Integer repaisId){
        return maintainService.getMaintain(repaisId);
    }

    @ApiOperation("转单修改")
    @PostMapping("AcceptedUpdate")
    public R AcceptedUpdate(@RequestBody Repais repais){
        return repaisService.AcceptedUpdate(repais);
    }
    @ApiOperation("转单修改")
    @PostMapping("TransferUpdate")
    public R TransferUpdate(@RequestBody Repais repais){
        return repaisService.TransferUpdate(repais);
    }
}
  